var fs = require('fs');
function strMapToObj(strMap) {
  let obj = Object.create(null);
  for (let [k,
    v]of strMap) {
    obj[k] = v;
  }
  return obj;
}

function strMapToJson(strMap) {
  return JSON.stringify(strMapToObj(strMap));
}
var myMap = new Map();
var readline = require('linebyline'),
  rl = readline('/Users/eh/Documents/mywork/abc/46，XX性反转合并掌跖角化过度.txt');
var temp1;
rl.on('line', function(line, lineCount, byteCount) {
  var regex = /【(.*)】/; //有【】
  var regex1 = /^[^【]|^$/;
  var regex2 = /^[^【】$]/; //没有中括号
  var regex3 = /^$/; //空白行
  if (line.match(regex)) {}
  if (line.match(regex)) { //匹配【】
    console.log(line);

    temp1 = line.match(regex).input.toString();
    myMap.set(temp1, '');
  } else if (line.match(regex1)) {

    if (line.match(regex2)) { //有值

      var value1 = myMap.get(temp1);
      var value = line.match(regex2).input;
      myMap.set(temp1, value1 + value);
    }
    if (line.match(regex3)) { //空白行
      var valueBlank1 = myMap.get(temp1);
      var valueBlank = line.match(regex3).input;
      myMap.set(temp1, valueBlank1 + valueBlank);
    }
  }
}).on('close', function() {
  var Datas = strMapToJson(myMap);
  fs.writeFile("./data.json", Datas, (err) => {})
});
